package com.yunxun.coinmessage.service;

import com.yunxun.coinmessage.dao.UserDao;
import com.yunxun.coinmessage.dao.UserRecomDao;
import com.yunxun.coinmessage.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserRecomService {
    @Autowired
    UserRecomDao userRecomDao;
    @Autowired
    UserDao userDao;
    public List<User> queryUserList(int uid){
        List<String> openidList=userRecomDao.queryOpenidList(uid);
        List<User> oldUserList=userDao.queryUserByOpenid(openidList);
        List<User> newUserList=new ArrayList<>();
        for(User user:oldUserList){
            switch (user.getChannel()){
                case "ADD_SCENE_SEARCH":user.setChannel("公众号搜索"); break;
                case "ADD_SCENE_ACCOUNT_MIGRATION":user.setChannel("公众号迁移"); break;
                case "ADD_SCENE_PROFILE_CARD":user.setChannel("名片分享"); break;
                case "ADD_SCENE_QR_CODE":user.setChannel("扫描二维码"); break;
                case "ADD_SCENE_PROFILE_LINK":user.setChannel("图文页内名称点击"); break;
                case "ADD_SCENE_PROFILE_ITEM":user.setChannel("图文页右上角菜单"); break;
                case "ADD_SCENE_OTHERS":user.setChannel("其它"); break;
                default:user.setChannel("未知");
            }
            newUserList.add(user);
        }
        return  newUserList;
    }
}
